A robust system of logging is crucial for
developer productivity, and to help you understand the
state of your application. You can install the
Cloud Logging agent on Compute Engine, and Amazon EC2 instances, to stream logs from third-party applications
into Cloud Logging. The logging agent is an
application based on Fluentd. When you write your logs
to existing log files, such as syslog in
your VM instance, the logging agents send
the logs to Cloud Logging. Cloud Logging is pre -configured in other
compute environments. Dataflow, Cloud Functions,
and App Engine, have built-in
support for logging. You can enable logging on
Google Kubernetes Engine, by simply enabling a checkbox
in the Cloud Console, when you set up a
container cluster. In Cloud Logging, you
can view your logs, and search for particular
types of messages. You can create custom
logs-based metrics and alerts, based on those metrics. Let's take a look at
the example here. There's a logs-based metric called HTTP underscore success, that filters all log messages with an HTTP response of 200. We have then set an
alert on that metric, to notify you when the number of successful HTTP requests is below 400 per second,
for five minutes. Logs-based metrics are a
really powerful feature, in that they alert
you to a problem, so that you can react to it before it becomes a major issue.